package ar.pmt.vista.decoradores;

import java.text.DecimalFormat;

import javax.servlet.jsp.PageContext;

import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;

public class PercentWrapper implements DisplaytagColumnDecorator
{
    private DecimalFormat percentFormat;

    public PercentWrapper()
    {
        percentFormat = new DecimalFormat("#,###,###.00 %");
    }

    public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media)
        throws DecoratorException
    {
        Float percent = (Float)columnValue;
        if (percent==null) {
        	return "";
        }
        return percentFormat.format(percent);
    }

}